<?php header("Content-type:text/html; Charset=utf-8");?>
<?php 
	include "../Php_Code/class/wsyS_CodeSet_1.php";
	date_default_timezone_set('PRC');
?>
<?php
	function Cake($input){
		$N_Str1 = $input;
		$url = $_SERVER['DOCUMENT_ROOT']."DAY/DAY4/File/json/Code.json";
		$json_Str1 = file_get_contents($url);
		$arr_sl1 = json_decode($json_Str1,true);
		
		
		$BL1 = "";
		$BL1 = $BL1 . $arr_sl1['standardcode']['sys_code']; 
		$BL1 = $BL1 . $arr_sl1['standardcode']['Sys_cut']; 
		$BL1 = $BL1 . Cake_1('ABCDEFGHIJKLMNOPQRSTUVWYZ',4) . Cake_2(6); 
		$BL1 = $BL1 . $arr_sl1['standardcode']['Sys_cut']; 
		$BL1 = $BL1 . (string)date("Ymd") . (string)date("his");  
		$BL1 = $BL1 . $arr_sl1['standardcode']['Sys_cut'];  
		$BL1 = $BL1 . Cake_2(6) . Cake_1('ABCDEFGHIJKLMNOPQRSTUVWYZ',2);  
		$BL1 = $BL1 . $arr_sl1['standardcode']['Sys_cut'];  
		if((string)$input=="1"){
			$BL1 = $BL1 . $arr_sl1['standardcode']['sys_userstr'];
		}else{
			$cd1 = strlen($arr_sl1['standardcode']['sys_userstr']);
			$cd2 = strlen((string)$input);
			$cd3 = 0;
			if((int)$cd1>(int)$cd2){
				$cd3 =(int)$cd1-(int)$cd2;
			}
			$cd4 = "";
			$BL1i = 0;
			$BL1ii = $cd3;
			while($BL1i<$BL1ii){
				$cd4 = $cd4 . "0";
				$BL1i = $BL1i + 1;
			}//while
			$cd4 = $cd4 . (string)$input;
			if(strlen($cd4)>30){
				$cd4 = substr($cd4,0,30);
			}//
			$BL1 = $BL1 . $cd4;
			
		}//if((String)$input=="1"    
		$BL1 = $BL1 . $arr_sl1['standardcode']['Sys_cut'];  
		$BL1 = $BL1 . $arr_sl1['standardcode']['sys_software'];  
		$BL1 = $BL1 . $arr_sl1['standardcode']['Sys_cut'];   
		$BL1 = $BL1 . $arr_sl1['standardcode']['sys_tailcode'];  
		

		
		$N_Str1 =  $BL1;
		return $N_Str1;
	}//Cake
	function Cake_1($str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",$length=1){
		$len=strlen($str)-1;
		$randstr='';
		for($i=0;$i<$length;$i++){
			$num=mt_rand(0,$len);
			$randstr .= $str[$num];
		}
		return $randstr;
	}
	function Cake_2($length=1){
		$nNum1 = "";
		$nRandi1=1;
		$nRandi11=$length;
		while($nRandi1<=$nRandi11){
			$nNum1 = $nNum1 . (String)rand(0,9);
			$nRandi1 = $nRandi1 + 1;
		}//while($nRandi1<=$
		return $nNum1;
	}//GetRandIntNum
	function CakeTM1($TStr1){
		$BL1 = "";
		$ws  = 10;
		$cd1 = strlen((string)$TStr1);
		$cd2 = 0;
		if((int)$cd1<$ws){
			$cd2 =$ws-(int)$cd1;
		}
		$cd3 = "";
		$BL1i2 = 0;
		$BL1ii2 = $cd2;
		while($BL1i2<$BL1ii2){
			$cd3 = $cd3 . "0";
			$BL1i2 = $BL1i2 + 1;
		}//while
		$BL1 = (string)$TStr1 . $cd3;
		if(strlen($BL1)>$ws){
			$BL1 = substr($BL1,0,$ws);
		}//
		$BL1 = $BL1 . (string)date("Ymd") . (string)date("his") . Cake_2(10) . "JL0001";
		return $BL1;
	}//CakeTM1
?>